package cache_service

import (
	"strconv"
	"strings"
)

type Agent struct {
	ID int

	PageNum  int
	PageSize int
	Keyword  string
}

const CacheAgent = "Cache_Agent"

func (a *Agent) GetAgentKey() string {
	return CacheAgent + "_" + strconv.Itoa(a.ID)
}

func (a *Agent) GetAgentsKey() string {
	keys := []string{
		CacheAgent,
		"LIST",
	}

	if a.ID > 0 {
		keys = append(keys, strconv.Itoa(a.ID))
	}
	if a.PageNum > 0 {
		keys = append(keys, strconv.Itoa(a.PageNum))
	}
	if a.PageSize > 0 {
		keys = append(keys, strconv.Itoa(a.PageSize))
	}
	if len(a.Keyword) > 0 {
		keys = append(keys, a.Keyword)
	}

	return strings.Join(keys, "_")
}
